const buf = Buffer.from([0x00, 0xff, 0x3, 0x4, 0x5]);
console.log(buf);
const json = JSON.stringify(buf);

// 输出: {"type":"Buffer","data":[1,2,3,4,5]}
console.log(json);

const copy = JSON.parse(json, (key, value) => {
  console.log("------------key :-----------------");
  console.log(key);
  console.log("------------value :-----------------");
  console.log(value);
  console.log("-------------return :------------");
  console.log(value && value.type === 'Buffer' ?Buffer.from(value.data) : value);

  return value && value.type === 'Buffer' ?
    Buffer.from(value.data) :
    value;
});
// 输出: <Buffer 01 02 03 04 05>
console.log(copy);
